package org.allen.mst4j.action;

import java.io.Serializable;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.allen.mst4j.domain.User;
import org.allen.mst4j.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@Scope("session")
@RequestMapping("/user")
public class UserAction implements Serializable{
	
	private static final long serialVersionUID = 1L;
	
	@Autowired
	private UserService service;
	
	@RequestMapping(value = "/{id}/info")
	@ResponseBody
	public Object info(@PathVariable Integer id,HttpServletRequest request,HttpServletResponse response) {
		System.out.println(123123);
		User user = new User();
//		user.setId(id);
//		user.setName("name");
		return user;
	}
	
	@RequestMapping(method = RequestMethod.POST)
	@ResponseBody
	public Object insert(HttpServletRequest request,HttpServletResponse response,User user) {
		return service.insert(user);
	}
}
